package com.eastfair.venueservice.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.eastfair.database.mybatis.typehandler.M9EncryptHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.venueservice.enumeration.WorkOrderDisposalModeEnum;
import com.eastfair.venueservice.enumeration.WorkOrderWorkOrderTypeEnum;
import com.eastfair.venueservice.enumeration.WorkOrderWorkOrderStatusEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 工单
 * </p>
 *
 * @author linan
 * @since 2023-04-25
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="vsm_work_order",autoResultMap = true)
@ApiModel(value = "WorkOrder", description = "工单")
@AllArgsConstructor
public class WorkOrder extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用（确认状态）：1是 已确认；0否 未确认
     */
    @ApiModelProperty(value = "是否启用（确认状态）：1是 已确认；0否 未确认")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用（确认状态）：1是 已确认；0否 未确认")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 订单编号
     */
    @ApiModelProperty(value = "订单编号")
    @Size(max = 255, message = "订单编号长度不能超过255")
    @TableField(value = "order_number", condition = LIKE)
    @Excel(name = "订单编号")
    private String orderNumber;

    /**
     * 工单编号
     */
    @ApiModelProperty(value = "工单编号")
    @Size(max = 255, message = "工单编号长度不能超过255")
    @TableField(value = "work_order_no", condition = LIKE)
    @Excel(name = "工单编号")
    private String workOrderNo;

    /**
     * 展会ID
     */
    @ApiModelProperty(value = "展会ID")
    @TableField(value = "exhibition_manage_id")
    @Excel(name = "展会ID")
    private Long exhibitionManageId;

    /**
     * 工单类型 #{SERVICE:服务工单;REPAIR:报修工单;CHECK:验收工单;WORK_OVERTIME:加班工单}
     */
    @ApiModelProperty(value = "工单类型 #{SERVICE:服务工单;REPAIR:报修工单;CHECK:验收工单;WORK_OVERTIME:加班工单}")
    @TableField(value = "work_order_type")
    @Excel(name = "工单类型 #{SERVICE:服务工单;REPAIR:报修工单;CHECK:验收工单;WORK_OVERTIME:加班工单}", replace = {"服务工单_SERVICE", "报修工单_REPAIR", "验收工单_CHECK", "加班工单_WORK_OVERTIME",  "_null"})
    private WorkOrderWorkOrderTypeEnum workOrderType;

    /**
     * 工单状态 #{ORDER_TO_BE_RECEIVED:待接单;PENDING:待处理;FINISH:已完成;REVOKE:已撤销;CANCEL:已作废}
     */
    @ApiModelProperty(value = "工单状态 #{ORDER_TO_BE_RECEIVED:待接单;PENDING:待处理;FINISH:已完成;REVOKE:已撤销;CANCEL:已作废}")
    @TableField(value = "work_order_status")
    @Excel(name = "工单状态 #{ORDER_TO_BE_RECEIVED:待接单;PENDING:待处理;FINISH:已完成;REVOKE:已撤销;CANCEL:已作废}", replace = {"待接单_ORDER_TO_BE_RECEIVED", "待处理_PENDING", "已完成_FINISH", "已撤销_REVOKE", "已作废_CANCEL",  "_null"})
    private WorkOrderWorkOrderStatusEnum workOrderStatus;

    /**
     * 工单客户主体id(服务商ID)
     */
    @ApiModelProperty(value = "工单客户主体id(服务商ID)")
    @TableField(value = "customer_subject_id")
    @Excel(name = "工单客户主体id(服务商ID)")
    private Long customerSubjectId;

    /**
     * 工单客户主体名称(企业名称)
     */
    @ApiModelProperty(value = "工单客户主体名称(企业名称)")
    @Size(max = 255, message = "工单客户主体名称(企业名称)长度不能超过255")
    @TableField(value = "customer_subject_name", condition = LIKE)
    @Excel(name = "工单客户主体名称(企业名称)")
    private String customerSubjectName;

    /**
     * 工单客户主体类型(服务商类型 字典MENU_AFFILIATION)
     */
    @ApiModelProperty(value = "工单客户主体类型(服务商类型 字典MENU_AFFILIATION)")
    @Size(max = 255, message = "工单客户主体类型(服务商类型 字典MENU_AFFILIATION)长度不能超过255")
    @TableField(value = "customer_subject_type", condition = LIKE)
    @Excel(name = "工单客户主体类型(服务商类型 字典MENU_AFFILIATION)")
    private String customerSubjectType;

    /**
     * 联系人
     */
    @ApiModelProperty(value = "联系人")
    @Size(max = 255, message = "联系人长度不能超过255")
    @TableField(value = "contact", condition = LIKE)
    @Excel(name = "联系人")
    private String contact;

    /**
     * 联系人手机号
     */
    @ApiModelProperty(value = "联系人手机号")
    @Size(max = 255, message = "联系人手机号长度不能超过255")
    @TableField(value = "contact_mobile", condition = LIKE,typeHandler = M9EncryptHandler.class)
    @Excel(name = "联系人手机号")
    private String contactMobile;

    /**
     * 展馆编码
     */
    @ApiModelProperty(value = "展馆编码")
    @Size(max = 255, message = "展馆编码长度不能超过255")
    @TableField(value = "space_code", condition = LIKE)
    @Excel(name = "展馆编码")
    private String spaceCode;

    /**
     * 展馆号
     */
    @ApiModelProperty(value = "展馆号")
    @Size(max = 255, message = "展馆号长度不能超过255")
    @TableField(value = "space_name", condition = LIKE)
    @Excel(name = "展馆号")
    private String spaceName;

    /**
     * 展位编码
     */
    @ApiModelProperty(value = "展位编码")
    @Size(max = 255, message = "展位编码长度不能超过255")
    @TableField(value = "site_code", condition = LIKE)
    @Excel(name = "展位编码")
    private String siteCode;

    /**
     * 展位号
     */
    @ApiModelProperty(value = "展位号")
    @Size(max = 255, message = "展位号长度不能超过255")
    @TableField(value = "site_name", condition = LIKE)
    @Excel(name = "展位号")
    private String siteName;

    /**
     * 接单主体(字典 SERVICE_PROVIDER_TYPE)
     */
    @ApiModelProperty(value = "接单主体(字典 SERVICE_PROVIDER_TYPE)")
    @Size(max = 255, message = "接单主体(字典 SERVICE_PROVIDER_TYPE)长度不能超过255")
    @TableField(value = "accept_subject_type", condition = LIKE)
    @Excel(name = "接单主体(字典 SERVICE_PROVIDER_TYPE)")
    private String acceptSubjectType;

    /**
     * 接单公司ID(接单主体是主场，配套服务商, 则存储服务商ID；如果是场馆，则存储场馆部门id)
     */
    @ApiModelProperty(value = "接单公司ID(接单主体是主场，配套服务商, 则存储服务商ID；如果是场馆，则存储场馆部门id)")
    @TableField(value = "accept_company_id")
    @Excel(name = "接单公司ID(接单主体是主场，配套服务商, 则存储服务商ID；如果是场馆，则存储场馆部门id)")
    private Long acceptCompanyId;

    /**
     * 所属服务部门/商名称
     */
    @ApiModelProperty(value = "所属服务部门/商名称")
    @Size(max = 255, message = "所属服务部门/商名称长度不能超过255")
    @TableField(value = "accept_company_name", condition = LIKE)
    @Excel(name = "所属服务部门/商名称")
    private String acceptCompanyName;

    /**
     * 实付金额
     */
    @ApiModelProperty(value = "实付金额")
    @TableField(value = "pay_amount")
    @Excel(name = "实付金额")
    private BigDecimal payAmount;

    /**
     * 支付方式 字典维护
     */
    @ApiModelProperty(value = "支付方式 字典维护")
    @Size(max = 255, message = "支付方式 字典维护长度不能超过255")
    @TableField(value = "pay_way", condition = LIKE)
    @Excel(name = "支付方式 字典维护")
    private String payWay;

    /**
     * 付款时间
     */
    @ApiModelProperty(value = "付款时间")
    @TableField(value = "pay_time")
    @Excel(name = "付款时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime payTime;

    /**
     * 备注信息
     */
    @ApiModelProperty(value = "备注信息")
    @Size(max = 255, message = "备注信息长度不能超过255")
    @TableField(value = "remark", condition = LIKE)
    @Excel(name = "备注信息")
    private String remark;

    /**
     * 工单描述
     */
    @ApiModelProperty(value = "工单描述")
    @Size(max = 255, message = "工单描述长度不能超过255")
    @TableField(value = "work_order_desc", condition = LIKE)
    @Excel(name = "工单描述")
    private String workOrderDesc;

    /**
     * 工单金额
     */
    @ApiModelProperty(value = "工单金额")
    @TableField(value = "work_order_amount")
    @Excel(name = "工单金额")
    private BigDecimal workOrderAmount;

    /**
     * 处理方式 #{CONSTRUCTION_AND_INSTALLATION:施工安装;EQUIPMENT_WARRANTY:设备保修;SITE_ACCEPTANCE:场地验收;OVERTIME_ON_SITE:现场加班;OTHER:其他}
     */
    @ApiModelProperty(value = "处理方式 #{CONSTRUCTION_AND_INSTALLATION:施工安装;EQUIPMENT_WARRANTY:设备保修;SITE_ACCEPTANCE:场地验收;OVERTIME_ON_SITE:现场加班;OTHER:其他}")
    @TableField(value = "disposal_mode")
    @Excel(name = "处理方式 #{CONSTRUCTION_AND_INSTALLATION:施工安装;EQUIPMENT_WARRANTY:设备保修;SITE_ACCEPTANCE:场地验收;OVERTIME_ON_SITE:现场加班;OTHER:其他}", replace = {"施工安装_CONSTRUCTION_AND_INSTALLATION", "设备保修_EQUIPMENT_WARRANTY", "场地验收_SITE_ACCEPTANCE", "现场加班_OVERTIME_ON_SITE", "其他_OTHER",  "_null"})
    private WorkOrderDisposalModeEnum disposalMode;


    @Builder
    public WorkOrder(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    String orderNumber, String workOrderNo, Long exhibitionManageId, WorkOrderWorkOrderTypeEnum workOrderType, WorkOrderWorkOrderStatusEnum workOrderStatus, Long customerSubjectId, 
                    String customerSubjectName, String customerSubjectType, String contact, String contactMobile, String spaceCode, String spaceName, 
                    String siteCode, String siteName, String acceptSubjectType, Long acceptCompanyId, String acceptCompanyName, BigDecimal payAmount, 
                    String payWay, LocalDateTime payTime, String remark, String workOrderDesc, BigDecimal workOrderAmount, WorkOrderDisposalModeEnum disposalMode) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.orderNumber = orderNumber;
        this.workOrderNo = workOrderNo;
        this.exhibitionManageId = exhibitionManageId;
        this.workOrderType = workOrderType;
        this.workOrderStatus = workOrderStatus;
        this.customerSubjectId = customerSubjectId;
        this.customerSubjectName = customerSubjectName;
        this.customerSubjectType = customerSubjectType;
        this.contact = contact;
        this.contactMobile = contactMobile;
        this.spaceCode = spaceCode;
        this.spaceName = spaceName;
        this.siteCode = siteCode;
        this.siteName = siteName;
        this.acceptSubjectType = acceptSubjectType;
        this.acceptCompanyId = acceptCompanyId;
        this.acceptCompanyName = acceptCompanyName;
        this.payAmount = payAmount;
        this.payWay = payWay;
        this.payTime = payTime;
        this.remark = remark;
        this.workOrderDesc = workOrderDesc;
        this.workOrderAmount = workOrderAmount;
        this.disposalMode = disposalMode;
    }

}
